package com.example.flink.wordcount;

import org.apache.flink.api.common.functions.FilterFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * Created with IntelliJ IDEA.
 * ClassName: StreamDemo
 * Package: com.example.flink.wordcount
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-07-20
 * Time: 20:47
 */

//转换算子 过滤
public class StreamDemo {
    public static void main(String[] args) throws Exception {
        //过滤出 单词有a的单词

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        env.setParallelism(1);

        DataStreamSource<String> data = env.readTextFile("./word.txt");

        final SingleOutputStreamOperator<String> filter = data.filter(new FilterFunction<String>() {

            //filter 只能输入什么数据 输出什么数据 切分单词之后数据改变了
            @Override
            public boolean filter(String value) throws Exception {
                //切割
                String[] s = value.split(" ");


                return false;

            }
        });

        filter.print();

        env.execute();

    }
}
